﻿
@{
    ViewBag.Title = "修改商户类型";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

@using Mate.Framework.Extensions
@model Mate.Db.Model.Merchant.mp_merchant_category

@section scripts{
    <script src="~/bootstrap/plugins/jquery-validation/dist/jquery.validate.min.js"></script>
    <script src="~/bootstrap/plugins/jquery-validation/dist/additional-methods.min.js"></script>
    <script src="~/bootstrap/scripts/custom/form-validation.js" charset="gbk"></script>

    <script src="~/js/admin.js?v=1.0"></script>
    <script language="javascript" type="text/javascript">
        $(function () {
            var rules = {
                merchantcategoryname: {
                    required: true
                },
                sortid: {
                    required: true,
                    digits: true
                }

            };
            FormValidation.BasicValidation(rules);

        });
    </script>
}

<ul class="page-breadcrumb breadcrumb">
    <li>
        <a href="@Url.Action("Index","MerchantCategory")">
            商户类型
        </a>
        <i class="fa fa-angle-right"></i>
    </li>
    <li>
        修改商户类型
    </li>
</ul>

<div class="row">
    <div class="col-md-12">
        <div class="portlet-body form">
            <!-- BEGIN FORM-->
            @using (Html.BeginForm("Edit", "MerchantCategory", FormMethod.Post, new { @class = "form-horizontal", @id = "form_ff_validation", @novalidate = "novalidate" }))
            {
            <div class="form-body">
                <div class="form-group">
                    <label class="control-label col-xs-3">
                        父类型
                        <span class="required">*</span>
                    </label>
                    <div class="col-xs-4">
                        <select id="parentid" name="parentid" class="form-control">
                            <option value="0">一级类型</option>
                            @if (ViewBag.MerchantCategoryList != null)
                            {
                                var list = ViewBag.MerchantCategoryList as IList<Mate.Dto.Merchant.MerchantCategoryTreeModel>;
                                var parentList = list.Where(x => x.parentid == 0).ToList();
                                foreach (var item in parentList)
                                {
                                    <option value="@(item.id)" @(item.id == Model.parentid ? "selected='selected'" : "")>@item.merchantcategoryname</option>
                                    if (item.children.Any())
                                    {
                                        foreach (var item2 in item.children)
                                        {
                                            <option value="@(item2.id)" @(item2.id == Model.parentid ? "selected='selected'" : "")>├── @item2.merchantcategoryname</option>
                                        }
                                    }
                                }
                            }
                        </select>
                    </div>
                </div>
                @Html.TextFor("名称", "merchantcategoryname", value: Model.merchantcategoryname)
                @Html.TextFor("排序", "sortid", value: Model.sortid.ToString())
                @Html.RadioFor("状态", "is_valid", new List<KeyValuePair<string, string>>()
                                                {
                                                    new KeyValuePair<string, string>("1","启用"),
                                                    new KeyValuePair<string, string>("2","禁用")
                                                },selectValue:Model.is_valid.ToString())

                @Html.RadioFor("是否热门", "is_hot", new List<KeyValuePair<string, string>>()
                                                {
                                                    new KeyValuePair<string, string>("1","是"),
                                                    new KeyValuePair<string, string>("0","否")
                                                },selectValue:Model.is_hot.ToString())


            </div>
                <div class="form-actions fluid">
                    <div class="col-md-offset-3 col-md-9">
                        @Html.HiddenFor(x=>x.id)
                        <button class="btn green" type="button" onclick="admin.AddSubmit('@Url.Action("Index")')"> 提交 <i class="fa fa-check"></i> </button>
                        <a class="btn default" role="button" href="@Url.Action("Index")"> 返回 <i class="fa fa-reply"></i></a>
                    </div>
                </div>
            }
            <!-- END FORM-->
        </div>
    </div>
    <!-- END VALIDATION STATES-->
</div>
